module IntegrationHelper
  
  def valid_user_credentials(params = {})
    User.new({ 
        :account_name => 'admin', 
        :password     => 'password'
    }.merge(params))
  end
  
  def setup_user(params = {})
    user = User.new({
      :account_name => 'roviler',
      :password => 'pass123',
      :location_id => locations(:uw_medical_center).id,
      :permission_level => 'client',
      :real_name => 'Robert Oliver',
      :email => 'roly@uw.edu',
      :phone_number => '333-444-5555'
    }.merge(params))
    assert user.save
    user
  end
  
  def login(user)
    post login_path, :account_name => user.account_name,
                     :password => user.password
    assert_redirected_to items_path
  end
  
  def logout
    post logout_path
    assert_redirected_to login_path
  end
end